package com.gmail.blackdog1987.carcare.util;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;

import org.apache.http.entity.mime.MultipartEntity;
import org.apache.http.entity.mime.content.StringBody;

import com.gmail.blackdog1987.carcare.entity.TGasCard;

public class MultipartEntityUtils {
	public static final void initGasCard(final MultipartEntity reqEntity, final TGasCard card){
		
		try {
			reqEntity.addPart("id", new StringBody(String.valueOf(card.id==null?1:card.id)));
			reqEntity.addPart("code", new StringBody(card.code==null?"":card.code));
			reqEntity.addPart("name", new StringBody(card.name==null?"":card.name, Charset.forName("UTF-8")));
			reqEntity.addPart("userid", new StringBody(card.userid==null?"0":String.valueOf(card.userid)));
			reqEntity.addPart("phone", new StringBody(card.phone==null?"":card.phone));
			reqEntity.addPart("price", new StringBody(card.price==null?"0":String.valueOf(card.price)));
			reqEntity.addPart("address", new StringBody(card.address==null?"":card.address, Charset.forName("UTF-8")));
			reqEntity.addPart("idcard", new StringBody(card.idcard==null?"":card.idcard));
			reqEntity.addPart("sendtime", new StringBody(String.valueOf(card.sendtime==null?0:card.sendtime)));
			reqEntity.addPart("idcardPic", new StringBody(card.idcardPic==null?"":card.idcardPic));
			reqEntity.addPart("idcardPic2", new StringBody(card.idcardPic2==null?"":card.idcardPic2));
			reqEntity.addPart("status", new StringBody(String.valueOf(card.status==null?1:card.status)));
			reqEntity.addPart("createtime", new StringBody(String.valueOf(card.createtime)));
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
